<html>
<head><meta charset="utf-8"><title>Converting \r\n -&gt; \n at file load time · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Converting.20.5Cr.5Cn.20-.3E.20.5Cn.20at.20file.20load.20time.html">Converting \r\n -&gt; \n at file load time</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="171386363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Converting%20%5Cr%5Cn%20-%3E%20%5Cn%20at%20file%20load%20time/near/171386363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Converting.20.5Cr.5Cn.20-.3E.20.5Cn.20at.20file.20load.20time.html#171386363">(Jul 21 2019 at 20:20)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> do we have an issue for normalizing newlines at file load time? I'd like to look into that. I've actually tried it already and I have questions about the expected behavior of <code>"\r\r\n"</code> :)</p>



<a name="171386838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Converting%20%5Cr%5Cn%20-%3E%20%5Cn%20at%20file%20load%20time/near/171386838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Converting.20.5Cr.5Cn.20-.3E.20.5Cn.20at.20file.20load.20time.html#171386838">(Jul 21 2019 at 20:35)</a>:</h4>
<p>I assumed <a href="https://github.com/rust-lang/rust/issues/60604" target="_blank" title="https://github.com/rust-lang/rust/issues/60604">https://github.com/rust-lang/rust/issues/60604</a> is the issue.</p>



<a name="171386955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Converting%20%5Cr%5Cn%20-%3E%20%5Cn%20at%20file%20load%20time/near/171386955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Converting.20.5Cr.5Cn.20-.3E.20.5Cn.20at.20file.20load.20time.html#171386955">(Jul 21 2019 at 20:39)</a>:</h4>
<p>Ah, that one, about raw byte strings, was closed by <a href="https://github.com/rust-lang/rust/pull/60793" target="_blank" title="https://github.com/rust-lang/rust/pull/60793">https://github.com/rust-lang/rust/pull/60793</a></p>



<a name="171387024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Converting%20%5Cr%5Cn%20-%3E%20%5Cn%20at%20file%20load%20time/near/171387024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Converting.20.5Cr.5Cn.20-.3E.20.5Cn.20at.20file.20load.20time.html#171387024">(Jul 21 2019 at 20:41)</a>:</h4>
<blockquote>
<p>expected behavior of "\r\r\n"</p>
</blockquote>
<p>Let me check what VC++ does when reading a file with Windows EOL in text mode.</p>



<a name="171388259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Converting%20%5Cr%5Cn%20-%3E%20%5Cn%20at%20file%20load%20time/near/171388259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Converting.20.5Cr.5Cn.20-.3E.20.5Cn.20at.20file.20load.20time.html#171388259">(Jul 21 2019 at 21:20)</a>:</h4>
<p>^^ <code>\r\r\n</code> is read as <code>\r\n</code></p>



<a name="171388337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Converting%20%5Cr%5Cn%20-%3E%20%5Cn%20at%20file%20load%20time/near/171388337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Converting.20.5Cr.5Cn.20-.3E.20.5Cn.20at.20file.20load.20time.html#171388337">(Jul 21 2019 at 21:23)</a>:</h4>
<p>Which seems reasonable since it's the simplest and fastest variant.<br>
And if you have things like <code>\r\r\n</code> in a <em>text</em> file, it's understandable if the compiler considers it your problem.</p>



<a name="171414771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Converting%20%5Cr%5Cn%20-%3E%20%5Cn%20at%20file%20load%20time/near/171414771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Converting.20.5Cr.5Cn.20-.3E.20.5Cn.20at.20file.20load.20time.html#171414771">(Jul 22 2019 at 09:10)</a>:</h4>
<p>The option with erroring on isolated <code>\r</code>s at load time also looks good to me.<br>
It would allow to do some cleanup in the lexer too.</p>



<a name="171414979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Converting%20%5Cr%5Cn%20-%3E%20%5Cn%20at%20file%20load%20time/near/171414979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Converting.20.5Cr.5Cn.20-.3E.20.5Cn.20at.20file.20load.20time.html#171414979">(Jul 22 2019 at 09:14)</a>:</h4>
<p>issue filed, by the way: <a href="https://github.com/rust-lang/rust/issues/62865" target="_blank" title="https://github.com/rust-lang/rust/issues/62865">https://github.com/rust-lang/rust/issues/62865</a></p>
<p>Yeah, I think I'll go with making this a hard error. This will make handling of "file &gt; 4GB" somewhat cleaner as well.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>